home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / DirectionButtonBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  8KB  |  223 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  09/07/97    LAB    Removed background, foreground, and font properties (Addresses Mac Bug #7668).
  8. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  9.  
  10. /**
  11.  * BeanInfo for DirectionButton.
  12.  *
  13.  */
  14.  
  15. public class DirectionButtonBeanInfo extends SimpleBeanInfo {
  16.  
  17.     /**
  18.      * Constructs a DirectionButtonBeanInfo object.
  19.      */
  20.     public DirectionButtonBeanInfo() {
  21.     }
  22.  
  23.     /**
  24.      * Gets a BeanInfo for the superclass of this bean.
  25.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  26.      */
  27.     public BeanInfo[] getAdditionalBeanInfo() {
  28.         try {
  29.             BeanInfo[] bi = new BeanInfo[1];
  30.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  31.             return bi;
  32.         }
  33.         catch (IntrospectionException e) { throw new Error(e.toString());}
  34.     }
  35.  
  36.     /**
  37.      * Gets the SymantecBeanDescriptor for this bean.
  38.      * @return an object of type SymantecBeanDescriptor
  39.      * @see symantec.itools.beans.SymantecBeanDescriptor
  40.      */
  41.     public BeanDescriptor getBeanDescriptor() {
  42.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  43.         String s=group.getString("GroupAWTAdditions"); 
  44.  
  45.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  46.         bd.setFolder(s);
  47.         bd.setToolbar(s);
  48.         bd.setWinHelp("0x123A2");
  49.  
  50.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  51.  
  52.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  53.                                                 "%name%.LEFT",
  54.                                                 conn.getString("LEFT")));
  55.  
  56.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  57.                                                 "%name%.RIGHT",
  58.                                                 conn.getString("RIGHT")));
  59.  
  60.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  61.                                                 "%name%.UP",
  62.                                                 conn.getString("UP")));
  63.  
  64.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  65.                                                 "%name%.DOWN",
  66.                                                 conn.getString("DOWN")));
  67.  
  68.         bd.addAdditionalConnections(getAdditionalBeanInfo());
  69.  
  70.         return (BeanDescriptor) bd;
  71.     }
  72.  
  73.     /**
  74.      * Gets an image that may be used to visually represent this bean
  75.      * (in the toolbar, on a form, etc).
  76.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  77.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  78.      * @return an image for this bean, always color even if requested monochrome
  79.      * @see BeanInfo#ICON_MONO_16x16
  80.      * @see BeanInfo#ICON_COLOR_16x16
  81.      * @see BeanInfo#ICON_MONO_32x32
  82.      * @see BeanInfo#ICON_COLOR_32x32
  83.      */
  84.     public java.awt.Image getIcon(int iconKind) {
  85.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  86.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  87.             java.awt.Image img = loadImage("DirectionButtonC16.gif");
  88.             return img;
  89.         }
  90.  
  91.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  92.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  93.             java.awt.Image img = loadImage("DirectionButtonC32.gif");
  94.             return img;
  95.         }
  96.  
  97.         return null;
  98.     }
  99.  
  100.     /**
  101.      * Gets an array of descriptions of the methods used for "connections" by
  102.      * Visual CafΘ's Interaction Wizard.
  103.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  104.      * @return method descriptions for this bean
  105.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  106.      */
  107.     public MethodDescriptor[] getMethodDescriptors() {
  108.         Class[] args;
  109.         ConnectionDescriptor connection;
  110.         java.util.Vector connections;
  111.         java.util.Vector md = new java.util.Vector();
  112.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  113.  
  114.         try{
  115.             args = new Class[1];
  116.             args[0] = java.lang.Integer.TYPE ;
  117.             MethodDescriptor setDirection = new MethodDescriptor(beanClass.getMethod("setDirection", args));
  118.  
  119.             connections = new java.util.Vector();
  120.             connection = new ConnectionDescriptor("input", "int", "",
  121.                                     "%name%.setDirection(%arg%);",
  122.                                     conn.getString("setDirection"));
  123.             connections.addElement(connection);
  124.  
  125.             setDirection.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  126.             md.addElement(setDirection);
  127.         } catch (Exception e) { throw new Error("setDirection:: " + e.toString()); }
  128.  
  129.         try{
  130.             args = null;
  131.             MethodDescriptor getDirection = new MethodDescriptor(beanClass.getMethod("getDirection", args));
  132.  
  133.             connections = new java.util.Vector();
  134.             connection = new ConnectionDescriptor("output", "int", "",
  135.                                     "%name%.getDirection()",
  136.                                     conn.getString("getDirection"));
  137.             connections.addElement(connection);
  138.  
  139.             getDirection.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  140.             md.addElement(getDirection);
  141.         } catch (Exception e) { throw new Error("getDirection:: " + e.toString()); }
  142.  
  143.         try{
  144.             args = new Class[1];
  145.             args[0] = java.awt.Color.class ;
  146.             MethodDescriptor setArrowColor = new MethodDescriptor(beanClass.getMethod("setArrowColor", args));
  147.  
  148.             connections = new java.util.Vector();
  149.             connection = new ConnectionDescriptor("input", "Color", "",
  150.                                     "%name%.setArrowColor(%arg%);",
  151.                                     conn.getString("setArrowColor"));
  152.             connections.addElement(connection);
  153.  
  154.             setArrowColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  155.             md.addElement(setArrowColor);
  156.         } catch (Exception e) { throw new Error("setArrowColor:: " + e.toString()); }
  157.  
  158.         try{
  159.             args = null;
  160.             MethodDescriptor getArrowColor = new MethodDescriptor(beanClass.getMethod("getArrowColor", args));
  161.  
  162.             connections = new java.util.Vector();
  163.             connection = new ConnectionDescriptor("output", "Color", "",
  164.                                     "%name%.getArrowColor()",
  165.                                     conn.getString("getArrowColor"));
  166.             connections.addElement(connection);
  167.  
  168.             getArrowColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  169.             md.addElement(getArrowColor);
  170.         } catch (Exception e) { throw new Error("getArrowColor:: " + e.toString()); }
  171.  
  172.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  173.         md.copyInto(rv);
  174.  
  175.         return rv;
  176.     }
  177.  
  178.     /**
  179.      * Returns descriptions of this bean's properties.
  180.      */
  181.     public PropertyDescriptor[] getPropertyDescriptors() {
  182.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  183.  
  184.         try{
  185.         PropertyDescriptor direction = new PropertyDescriptor("direction", beanClass);
  186.         direction.setBound(true);
  187.         direction.setConstrained(true);
  188.         direction.setDisplayName(prop.getString("direction"));
  189.         direction.setValue("ENUMERATION", "LEFT=0, RIGHT=1, UP=2, DOWN=3");
  190.  
  191.         PropertyDescriptor arrowIndent = new PropertyDescriptor("arrowIndent", beanClass);
  192.         arrowIndent.setBound(true);
  193.         arrowIndent.setConstrained(true);
  194.         arrowIndent.setDisplayName(prop.getString("arrowIndent"));
  195.  
  196.         PropertyDescriptor arrowColor = new PropertyDescriptor("arrowColor", beanClass);
  197.         arrowColor.setBound(true);
  198.         arrowColor.setConstrained(true);
  199.         arrowColor.setDisplayName(prop.getString("arrowColor"));
  200.  
  201.         PropertyDescriptor background = new PropertyDescriptor("background", beanClass);
  202.         background.setHidden(true);
  203.  
  204.         PropertyDescriptor foreground = new PropertyDescriptor("foreground", beanClass);
  205.         foreground.setHidden(true);
  206.  
  207.         PropertyDescriptor font = new PropertyDescriptor("font", beanClass);
  208.         font.setHidden(true);
  209.  
  210.         PropertyDescriptor[] rv = {
  211.             direction,
  212.             arrowIndent,
  213.             arrowColor,
  214.             background,
  215.             foreground,
  216.             font};
  217.         return rv;
  218.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  219.     }
  220.  
  221.     private final static Class beanClass = DirectionButton.class;
  222.  
  223.     }    //  end of class DirectionButtonBeanInfo